// @charset "utf-8";
/**
 * 切换控制器
 */
define(function (require, exports, module) {
	var ggzdView = require('./ggzdview');
	var xgsgView = require('./xgsgview');
	var rzrqView = require('./rzrqview');
	var autoLoop = require('../base/autoloop');

	var control = {
		autodo : function () {
			var self = this;
			var tradingDay = commonMethod.getTradingDay();
			autoLoop.tradingDay = tradingDay;
			autoLoop.autodo(function (isIn) {
				ggzdView.autoRefresh(isIn);
			}, 60000, function (date) {
				self.init(date);
			});
		},
		init : function (date) {
			xgsgView.request();
			var timeBool0930 = commonMethod.judgeIntime(['00:00', '09:30']);
			var timeBool2359 = commonMethod.judgeIntime(['09:30', '23:59']);

			if (timeBool0930 && xgsgView.hasIpo) {
				// xgsg
				interactions.switchDefTab(1);
				xgsgView.request();
			} else if (timeBool0930) {
				// rzrq
				interactions.switchDefTab(2);
				rzrqView.request();

			} else if (timeBool2359) {
				if (date) {
					ggzdView.date = date;
					ggzdView.requestData();
				}
				// ggzd
				interactions.switchDefTab(0);
			}
		}
	};
	module.exports = control;
});